/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.saar.penguin.give2.mapviewer;

import give.world.World;
import javax.swing.JFrame;

/**
 *
 * @author koller
 */
public class MapViewerFrame extends JFrame {
    private JMapViewer mapViewer;
    private World world;

    public MapViewerFrame(String title, World world) {
        super(title);
        open(world);
    }

    public void open(World world) {
        getContentPane().removeAll();

        this.world = world;

        mapViewer = new JMapViewer(world);
        getContentPane().add(mapViewer);
        pack();
    }

    public void addControllerArrows() {
        ControllerArrowsPlugin controllerArrows = new ControllerArrowsPlugin(world, mapViewer);
        mapViewer.addMouseOverObjectListener(controllerArrows);
        mapViewer.addMapAnnotationPlugin(controllerArrows);
    }

    public void addTooltips() {
        MapViewerTooltipOverlay mgp = new MapViewerTooltipOverlay(world, mapViewer);
        mapViewer.addMouseOverObjectListener(mgp);
        mapViewer.addMapAnnotationPlugin(mgp);
    }

    public void display() {
        pack();
        setVisible(true);
        setResizable(false);
    }

    public JMapViewer getMapViewer() {
        return mapViewer;
    }
}
